package ynu.edu;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableDiscoveryClient
@RestController
@RefreshScope
public class Provider2Application11002 {

    // 从配置中心读取配置
    @Value("${app.message:Default Provider2 Message}")
    private String configMessage;

    @Value("${app.version:1.0.0}")
    private String version;

    @Value("${app.data.provider-info:Default Provider2 Info}")
    private String providerInfo;

    @GetMapping("/provide")
    public String provider() {
        return "Provider2的服务 - " + configMessage;
    }

    @GetMapping("/config")
    public String getConfig() {
        return "Provider2 Config - Message: " + configMessage + ", Version: " + version + ", Info: " + providerInfo;
    }

    public static void main(String[] args) {
        SpringApplication.run(Provider2Application11002.class, args);
    }
}